package com.dot.dominion.domain;

import com.dot.dominion.Constants;

public class SupplyPile extends Deck {
	private int embargoTokens;	//Embargo tokens charged
	
	/**
	 * Constructor for Action Cards
	 * 
	 * Called during game setup
	 * 
	 * @param card		The Card held within the SupplyPile
	 */
	public SupplyPile( Card card ) {
		this( card, Constants.STARTING_SUPPLY_SIZE );
	}

	/**
	 * Constructor for Treasure & Victory Cards
	 * 
	 * Called during game setup.
	 * 
	 * @param card			The Card held within the SupplyPile
	 * @param supplyCount	The amount of cards
	 */
	public SupplyPile( Card card, int supplyCount ) {
		super();

		while( size() < supplyCount )
			addToDeck( new Card(card) );
		
		embargoTokens = 0;
	}

	/**
	 * Buying a card in order to obtain it.
	 * 
	 * Checks if you can afford it. If you can, you get it. Otherwise
	 * it gives you nothing.
	 * 
	 * @param coins		The amount of Coin you possess
	 * @return			The Card in the SupplyPile
	 * 					null:	* The SupplyPile is empty
	 * 							* You cannot afford it
	 */
	/*
	public Card buyCard(int coins) {
		if( deck.empty() )
			return null;
		
		if( getCost() >= coins )
			return draw();
		else
			return null;
	}
	*/
	
	/**
	 * Gain a card.
	 * 
	 * This is used when you do not need to obtain this card during the Buy
	 * Phase. Usually done through a Card's ability.
	 * 
	 * @return	The Card in the SupplyPile
	 */
	/*
	public Card gainCard() {
		return draw();
	}
	*/

	/**
	 * Get a card.
	 * 
	 * @return	The Card in the SupplyPile
	 */
	public Card getCard() {
		return draw();
	}
	
	/**
	 * Get the cost of the Card within the SupplyPile
	 */
	public int getCost() {
		if(! isEmpty() )
			return ( peekAtTop() ).getCost();
		else
			return Constants.GENERAL_ERROR;
	}

	/**
	 * Get the amount of cards left within the SupplyPile
	 * 
	 * @return	The amount of Cards remaining
	 */
	public int getCount() {
		return size();
	}
	
	/**
	 * Get the number of Embargo Tokens charged against the SupplyPile
	 * 
	 * @return	The number of charged Embargo Tokens.
	 */
	public int getEmbargoTokens() {
		return embargoTokens;
	}
}